<template>
  <div class="clue-list-container">
    <el-card class="content-card">
      <template #header>
        <div class="card-header">
          <span>线索列表</span>
          <el-button type="primary">新增线索</el-button>
        </div>
      </template>

      <!-- 搜索过滤区 -->
      <div class="search-container">
        <el-input
          v-model="searchForm.keyword"
          placeholder="请输入客户姓名/电话"
          style="width: 300px"
          clearable
        />
        <el-select
          v-model="searchForm.status"
          placeholder="请选择状态"
          style="width: 160px; margin-left: 10px"
          clearable
        >
          <el-option label="待跟进" value="待跟进" />
          <el-option label="跟进中" value="跟进中" />
          <el-option label="已转化" value="已转化" />
          <el-option label="已放弃" value="已放弃" />
        </el-select>
        <el-button type="primary" style="margin-left: 10px">搜索</el-button>
        <el-button style="margin-left: 10px">清空</el-button>
      </div>

      <!-- 线索列表 -->
      <el-table :data="clueList" style="width: 100%; margin-top: 20px">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="id" label="线索ID" width="100" />
        <el-table-column prop="customerName" label="客户姓名" width="150" />
        <el-table-column prop="phone" label="联系电话" width="150" />
        <el-table-column prop="source" label="线索来源" width="120" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="scope">
            <el-tag :type="getStatusType(scope.row.status)">
              {{ scope.row.status }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="180" />
        <el-table-column prop="owner" label="负责人" width="120" />
        <el-table-column label="操作" width="180" fixed="right">
          <template #default>
            <el-button type="primary" size="small">查看</el-button>
            <el-button size="small">跟进</el-button>
            <el-button type="danger" size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <div class="pagination-container">
        <el-pagination
          v-model:current-page="pagination.currentPage"
          v-model:page-size="pagination.pageSize"
          :page-sizes="[10, 20, 50, 100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pagination.total"
        />
      </div>
    </el-card>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'

// 搜索表单
const searchForm = reactive({
  keyword: '',
  status: ''
})

// 分页信息
const pagination = reactive({
  currentPage: 1,
  pageSize: 10,
  total: 100
})

// 线索列表数据
const clueList = ref([
  { id: 'CL001', customerName: '张三', phone: '138****1234', source: '官网', status: '待跟进', createTime: '2025-01-20 10:30:00', owner: '李四' },
  { id: 'CL002', customerName: '李四', phone: '139****5678', source: '微信', status: '跟进中', createTime: '2025-01-20 14:20:00', owner: '王五' },
  { id: 'CL003', customerName: '王五', phone: '137****9012', source: '推荐', status: '已转化', createTime: '2025-01-19 09:15:00', owner: '赵六' },
  { id: 'CL004', customerName: '赵六', phone: '136****3456', source: '展会', status: '已放弃', createTime: '2025-01-18 16:40:00', owner: '钱七' },
  { id: 'CL005', customerName: '钱七', phone: '135****7890', source: '电话', status: '待跟进', createTime: '2025-01-17 11:10:00', owner: '孙八' }
])

// 根据状态获取标签类型
const getStatusType = (status) => {
  const typeMap = {
    '待跟进': 'info',
    '跟进中': 'warning',
    '已转化': 'success',
    '已放弃': 'danger'
  }
  return typeMap[status] || 'default'
}
</script>

<style scoped>
.clue-list-container {
  padding: 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-container {
  display: flex;
  align-items: center;
  margin-top: 20px;
}

.pagination-container {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>